// 约定一个通用的键名
const INFO_KEY = 'hm_shopping_info'
const HISTORY_KEY = 'history_info'
// 获取用户信息
export const getInfo = () => {
    const defaultObj = { token: '', userId: '' }
    const result = localStorage.getItem(INFO_KEY)
    return result ? JSON.parse(result) : defaultObj
}
// 设置用户信息
export const setInfo = (obj) => {
    localStorage.setItem(INFO_KEY, JSON.stringify(obj))
}
// 移除用户信息
export const removeInfo = () => {
    localStorage.removeItem(INFO_KEY)
}

// 获取查询历史数据
export const getHistory = () => {
    const result = localStorage.getItem(HISTORY_KEY)
    return result ? JSON.parse(result) : []
}
// 设置查询历史数据
export const setHistory = (obj) => {
    localStorage.setItem(HISTORY_KEY, JSON.stringify(obj))
}